package main
 
import (
    "fmt"
    "time"
)

func main() {
	c := make(chan int, 0)

	fmt.Printf("len=%d, cap=%d\n", len(c), cap(c))

	go func() {
		defer fmt.Println("child end")

		for i := 0; i < 3; i++ {
			c <- i 
			fmt.Printf("子go程正在运行[%d]: len(c)=%d, cap(c)=%d\n", i, len(c), cap(c))

		}
	}()

	time.Sleep(2 * time.Second)

	for i := 0; i < 3; i++ {
		num := <- c 
		fmt.Println("num =", num)
	}

	fmt.Println("main end")
}